package com.example.zhihuhelpapp.adapter;

import android.content.Context;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.example.zhihuhelpapp.R;
import com.example.zhihuhelpapp.bean.QuestionDataFormExcel;
import com.zhy.adapter.recyclerview.CommonAdapter;
import com.zhy.adapter.recyclerview.base.ViewHolder;

import java.util.List;

public class QuestionFromExcelListAdapter extends CommonAdapter<QuestionDataFormExcel> {
    public QuestionFromExcelListAdapter(Context context, List<QuestionDataFormExcel> datas) {
        super(context, R.layout.item_question_from_excel, datas);
    }

    @Override
    protected void convert(ViewHolder viewHolder, QuestionDataFormExcel data, int i) {
        TextView tv_question_title = viewHolder.getView(R.id.tv_question_title);
        TextView tv_answer_data = viewHolder.getView(R.id.tv_answer_data);
        Button mBtnGetRaking = viewHolder.getView(R.id.mBtnGetRaking);
        Button mBtnSave = viewHolder.getView(R.id.mBtnSave);

        tv_question_title.setText(data.getTitle());
        tv_answer_data.setText("阅读量：" + data.getReadCount() + " 点赞量：" + data.getStartCount() +
                " 收藏量：" + data.getCollectCount() + " 评论量：" + data.getCommentCount() + " 喜欢量：" + data.getLikeCount());

        mBtnGetRaking.setOnClickListener(onItemChildClickListener);
        mBtnSave.setOnClickListener(onItemChildClickListener);
    }

    private View.OnClickListener onItemChildClickListener;

    public void setOnItemChildClickListener(View.OnClickListener onItemChildClickListener) {
        this.onItemChildClickListener = onItemChildClickListener;
    }
}
